home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Shareware / Programare / magiccd / mcdbc111t.exe / %MAINDIR% / Memory Burning / Unit1.cpp < prev   
Encoding:
C/C++ Source or Header  |  2004-03-08  |  2.3 KB  |  68 lines

  1. //---------------------------------------------------------------------------
  2. #include "stdafx.h"
  3. #include "..\..\include\MCDBcls.h"
  4. #include <conio.h>
  5.  
  6. //---------------------------------------------------------------------------
  7. void static __stdcall OnWriteDone(BOOL, void *);
  8. void static __stdcall OnGetData(HANDLE FileHandle, unsigned long Position, void *buffer, unsigned long *Size, void *arg);
  9.  
  10. void *MemoryFileHandle;
  11.  
  12. BOOL WriteDone = FALSE;
  13. CMCDBurner mcdb;
  14. int main(int argc, char* argv[])
  15. {        
  16.         WIN32_FIND_DATA FindData;
  17.         void *ps = NULL; //(void *)this
  18.         SYSTEMTIME st;
  19.         mcdb.ClearAll();
  20.         mcdb.SelectDevice(0);
  21.         memset(&FindData, 0, sizeof(FindData));
  22.         GetSystemTime(&st); SystemTimeToFileTime(&st, &FindData.ftLastWriteTime); // Get and Set current Data and Time
  23.         strcpy(FindData.cFileName, "MemoryFile"); // Long File Name
  24.         strcpy(FindData.cAlternateFileName, "MEMORYFI.LE");  /// Short File Name
  25.         FindData.nFileSizeLow = 1024000;  /// File Size
  26.         MemoryFileHandle = mcdb.InsertMemoryFile("\\", FindData, &OnGetData, ps);
  27.         mcdb.Prepare();
  28.         if (mcdb.TestUnitReady())
  29.         {
  30.           WriteDone = FALSE;
  31.           if (mcdb.BuildISOImage("c:\\test.iso", &OnWriteDone, NULL) == TRUE)
  32.           {
  33.              while (!WriteDone)
  34.              {
  35.                  SleepEx(100, TRUE);
  36.              }
  37.              getch();
  38.           }
  39.           else
  40.           {
  41.              printf(">>> Error! ...\n");
  42.           }
  43.         }
  44.         else
  45.         {
  46.              printf(">>> Drive not ready ...\n");
  47.         }
  48.         return 0;
  49. }
  50. //---------------------------------------------------------------------------
  51. void __stdcall OnGetData(HANDLE FileHandle, unsigned long Position, void *buffer, unsigned long *Size, void *arg)
  52. {
  53.    if (MemoryFileHandle == FileHandle)
  54.      memset(buffer, 255, *Size);
  55.    printf("Position: %ld - %ld\n", Position, Position+*Size);
  56. }
  57. //---------------------------------------------------------------------------
  58. void __stdcall OnWriteDone(BOOL FAILED, void *arg)
  59. {
  60.     if (FAILED)
  61.       printf(">>> WRITE DONE WITH ERROR (%d)\n", mcdb.GetErrorNumber());
  62.     else
  63.       printf(">>> WRITE DONE, NO ERROR.\n");
  64.     printf("Press any key to continue");
  65.     WriteDone = TRUE;
  66. }
  67.  
  68.